package business.impls.commons;

import business.interfaces.commons.DataProvider;
import business.interfaces.stores.XMLStore;

import java.util.Properties;

/**
 * Created by IntelliJ IDEA.
 * User: alex
 * Date: 07.04.2005
 * Time: 16:45:00
 * To change this template use File | Settings | File Templates.
 */
public class implDataProvider implements DataProvider{
    private jdbcTable table = null;

    public implDataProvider(){
        this.table = new jdbcTable();
    }
    private String Driver = "";
    private String jdbc = "";
    private String Uname = "";
    private String UPass = "";

    public void setSQLDriver(String Name){
        this.Driver = Name;
    }

    public void setSQLUrl(String Url){
        this.jdbc = Url;
    }
    public void setUserName(String UserName){
        this.Uname = UserName;
    }

    public void setUSerPassword(String UserPassword){
        this.UPass = UserPassword;
    }

    public int OpenConnection(){
        this.table = new jdbcTable();
        this.table.setJDBCDriver(this.Driver);
        this.table.setJDBCurl(this.jdbc);
        Properties pr = new Properties();
        pr.put("user",this.Uname);
        pr.put("password",this.UPass);
        pr.put("characterEncoding","cp1251");
        this.table.setJDBCprops(pr);
        this.table.setQuery("SHOW TABLES;");
        return this.table.Prepare();
    }

    public jdbcTable getSQLStore() {
        jdbcTable tmp = new jdbcTable();
        tmp.setConnection(this.table.getConnection());
        return tmp;
    }

    public XMLStore getXMLStore() {
        return null;  //To change body of implemented methods use File | Settings | File Templates.
    }
}
